package com.wwj.admin.player.controller;

import com.wwj.core.wawa.entity.PlayerItem;
import com.wwj.core.wawa.service.IPlayerItemService;
import com.wwj.core.wawa.service.IPlayerService;
import com.wwj.framework.controller.BaseController;
import com.wwj.framework.utils.Page2EasyUiData;
import com.wwj.framework.utils.ReturnData;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * Created by Auser on 2017/11/4.
 */

@Controller
@RequestMapping(value = "/player/item")
public class PlayerItemController extends BaseController {

    private final String INDEX = "/admin/player/item";
    @Resource
    private IPlayerService playerService;
    @Resource
    private IPlayerItemService playerItemService;

    @RequestMapping(value = {"","/","/index"})
    public String item()throws Exception{
        return INDEX;
    }

    @RequestMapping("/listData.json")
    @ResponseBody
    public ReturnData list(String search,int offset,int limit)throws Exception{
        playerService.selectPlayerItemByPage(search,offset,limit);
        return new ReturnData().success(Page2EasyUiData.format(playerService.selectPlayerItemByPage(search,offset,limit)));
    }

    @RequestMapping("/manualRecharge")
    @ResponseBody
    public ReturnData manualRecharge(int id,int itemNum,String description)throws Exception{
        PlayerItem playerItem = new PlayerItem();
        playerItem.setId(id);
        playerItem.setItemNum(itemNum);
        playerItemService.updatePlayerItem(playerItem,description);
        return new ReturnData().success("充值成功");
    }
}
